package com.springsummer.information.green.io;

import java.io.*;
import java.net.URL;

public class FileSystemResource implements Resource {

    private String path;

    private File file;

    public FileSystemResource(String path) {

        this.path = path;
        this.file = new File(this.path);

    }


    @Override
    public InputStream getInputStream() throws IOException {
        try {
            return new FileInputStream(file);
        } catch (Exception ex) {
            throw new FileNotFoundException(ex.getMessage());
        }
    }

    @Override
    public URL getURL() throws IOException {
        return this.file.toURI().toURL();
    }

    @Override
    public File getFile() throws IOException {
        return file;
    }

    @Override
    public boolean isFile() {
        return true;
    }


}
